package thread;

import java.util.concurrent.atomic.AtomicInteger;

public class RunnableThreadTest implements Runnable{

    private static final AtomicInteger atomic = new AtomicInteger(0);

    Resources resources = new Resources();

    public void run()
    {
        resources.Thread_competition();
    }
    public static void main(String[] args) throws InterruptedException {
        long startTime=System.currentTimeMillis();
        RunnableThreadTest rtt = new RunnableThreadTest();
        for (int i = 0;i<=10;i++){
            Thread thread = new Thread(rtt, "新线程" + i);
            /*while (atomic.get() != i) {
            }*/
            thread.start();
            System.out.println("atomic"+atomic.incrementAndGet());
            thread.join();
        }
        long endTime=System.currentTimeMillis();
        System.out.println("程序运行时间： "+(endTime - startTime)+"ms");
    }

}
